Deep Learning-Aided Automated Pneumonia Detection and Classification Using CXR Scans

The COVID-19 pandemic has caused a worldwide catastrophe and widespread devastation that reeled almost all countries. The pandemic has mounted pressure on the existing healthcare system and caused panic and desperation. The gold testing standard for COVID-19 detection, reverse transcription-polymerase chain reaction (RT-PCR), has shown its limitations with 70% accuracy, contributing to the incorrect diagnosis that exaggerated the complexities and increased the fatalities. The new variations further pose unseen challenges in terms of their diagnosis and subsequent treatment. The COVID-19 virus heavily impacts the lungs and fills the air sacs with fluid causing pneumonia. Thus, chest X-ray inspection is a viable option if the inspection detects COVID-19-induced pneumonia, hence confirming the exposure of COVID-19. Artificial intelligence and machine learning techniques are capable of examining chest X-rays in order to detect patterns that can confirm the presence of COVID-19-induced pneumonia. This research used CNN and deep learning techniques to detect COVID-19-induced pneumonia from chest X-rays. Transfer learning with fine-tuning ensures that the proposed work successfully classifies COVID-19-induced pneumonia, regular pneumonia, and normal conditions. Xception, Visual Geometry Group 16, and Visual Geometry Group 19 are used to realize transfer learning. The experimental results were promising in terms of precision, recall, F1 score, specificity, false omission rate, false negative rate, false positive rate, and false discovery rate with a COVID-19-induced pneumonia detection accuracy of 98%. Experimental results also revealed that the proposed work has not only correctly identified COVID-19 exposure but also made a distinction between COVID-19-induced pneumonia and regular pneumonia, as the latter is a very common disease, while COVID-19 is more lethal. These results mitigated the concern and overlap in the diagnosis of COVID-19-induced pneumonia and regular pneumonia. With further integrations, it can be employed as a potential standard model in differentiating the various lung-related infections, including COVID-19.


Introduction
e coronavirus disease (COVID- 19) was first identified in the city of Wuhan in China in 2019. As it transcended nations, growing in its impact and severity, the WHO declared it a pandemic. is viral infection peaked at different times in different countries, causing a global calamity. Even in 2022, with each passing day, thousands of new cases are being recorded along with hundreds of deaths. Currently, the total number of COVID-19 cases stands at 26.4 million with 5.25 million casualties worldwide [1]. e affected individual suffers from a series of symptoms and medical complications, depending upon their underlying medical conditions or comorbidities. e current testing methods, such as reverse transcription-polymerase chain reaction (RT-PCR), antigen, and antibody tests, are limited, expensive, and laborious and require a specialized technology, which is often not accessible in remote locations [2]. Moreover, despite being the gold standard, RT-PCR has an accuracy of only 70%. Aside from this, one of the complications arising from COVID-19 exposure includes lung pneumonia, which causes the air sacs in the lung to be filled with fluid. erefore, investigating chest X-rays becomes essential here, as COVID-19-induced pneumonia can confirm the presence of a COVID-19 infection. However, the symptoms of COVID-19 and other lung inflammatory infections overlap, which makes it prone to misdiagnosis and false positive cases. Figures 1 and 2 illustrate the heatmap of COVID-19 hotspots and the number of deaths due to it [3].
In this regard, artificial intelligence and machine learning techniques have the ability to detect a given pattern from the images. e present paper embraced the ideas of deep leaning, such as Visual Geometry Group 16,19, and Xception for chest X-rays, to detect COVID-19-induced pneumonia via pretrained models. e proposed model was trained and tested on various architectures to ensure its efficiency and accuracy in classifying chest X-ray images. It used the transfer learning approach with fine-tuning for this purpose.
e experimental results demonstrate successful classification of COVID-19-induced pneumonia, normal pneumonia, and normal conditions, thus allaying fear of overlap.
ese results are encouraging and calculated in terms of precision, recall, F1 score, specificity, false omission rate, false negative rate, false positive rate, and false discovery rate with a COVID-19 detection of almost 98%. is paper is organized as follows: Section 2 covers the related work; Section 3 represents the proposed work using chest X-ray scans; Section 4 presents the experimental results and analysis with comparison from the current state of art; and Section 5 provides the conclusion.

Related Work
Artificial intelligence (AI) and big data are of great importance in terms of reacting to the pandemic, along with predicting and analyzing patterns of various strains of viruses.

Background Study.
e proposed research aims to classify COVID-19-induced pneumonia, regular pneumonia, and healthy patients by using different learning methodologies. Machine learning (ML) is defined as a technique to train a computer to perform tasks that they are not explicitly programmed to do so. It is divided into various types depending on the category of the dataset being utilized as shown in Figure 3. If machine learning is implemented on labeled data, it is known as supervised machine learning, while working on unlabeled data is known as unsupervised machine learning. Similarly, deep learning is also one of the categories based on artificial neural networks. Deep learning architectures like deep neural network, deep belief network, recurrent neural network, and convolutional neural network (CNN) are implemented in the fields of computer vision, natural language processing, and speech recognition. e depth in deep learning signified the artificial neural networks, which are inspired by the human brain, comprised of neurons too which ideally mimic the learning abilities of a human being. e implementation of the suitable machine learning methods and the selection of dataset were the crucial steps when training the model. On the data, various preprocesses, rescaling, and other steps were carried out to make feature extraction easy. In this context, deep learning is preferred, and it reduced the dependency on features by utilizing nonlinear layers for feature extraction [4]. By using sequential layers, it made hierarchical selection based on what features best represented the data, rather than doing a manual feature selection.
e clinical symptoms of COVID-19 comprise fever, dry cough, tiredness, respiratory distress, and much more, which are like that of bronchopneumonia [5,6]. Medical images like chest X-rays are readily available, and chest X-rays of most COVID-19 cases are bilateral, round-glass opacities with a posterior distribution or peripheral, multifocal, and do remain mainly in the lower lobe of the lung in the early stages [7][8][9]. ereafter, it progresses and does pulmonary consolidation in the later stages [10,11]. Nevertheless, chest X-rays can help in the detection of suspected COVID-19 cases and conditions after it. However, this may lead to ambiguities in the diagnosis of the patient as the chest X-ray images can be identical to multiple other lung diseases, thus requiring further clinical corelation analysis. Such inaccurate diagnoses can lead to common pneumonia being confused with COVID-19 and can cause panic, cost, and unnecessary exposure with COVID-19-positive patients and can be fatal.

Transfer
Learning. Data dependency is one of the most complicated issues in deep learning, where adequate training involves a large amount of knowledge to help the network understand data patterns. In the sense of deep learning, all training and testing data are presumed to have the same distribution and feature space. In fact, appropriate training data can exist in one area, while the task of classification is carried out in another. Additionally, if the distribution of data shifts to the target domain, a complete reconstruction of the classification network with the newly collected training dataset is necessary. e CNN models based on transfer learning have advantages such as limited preprocessing of the data, faster learning time, and lower time complexity by reducing the irrelevant parameters. Also, it worked well on the limited dataset, making it ideal for the task of classification of medical images [12]. Group 16. Visual geometry group network (VGGNet) is a CNN architecture that focuses on the effect of the convolutional neural network depth on its accuracy [13]. Both versions, namely, VGGNet 19 and VGGNet 16, comprised of two fully connected layers along with 4,096 channels each, which in turn were followed by yet another fully connected layer comprising of 1,000 channels in order to obtain 1,000 labels. e softmax activation function is utilized by the last fully connected layer for classification purposes.

Visual Geometry Group 19 and Visual Geometry
VGG16 is a 16 multilayered architecture proposed by the visual geometry group laboratory at the University of Oxford. It is one of the more widely used architectures because it is composed of 138 million parameters. VGG16 is comprised of 13 convolutional and five maxpool layers. e convolutional layers contained 64 channels as input and output in the dimensions of 224 × 224 × 64.
e ImageNet database is comprised of a fixed input size of 224 × 224 and RGB channels, so the input can be defined as a tensor of (224, 224, 3), which can process the image Computational Intelligence and Neuroscience 3 input up to 1,000 vectors. e vector represented as x shows the classification probability for the given class in e vector in equation (2) presents classification probability for the relevant class. For example, the model predicts a probability of 0.1 for class 0, probability of 0.05 for class 1, probability of 0.05 for class 2, probability of 0.03 for class 3, probability of 0.72 for class 780, and a probability of 0.05 for class 999, while 0 is assigned to the rest of the classes. us, the classification vector x can be redefined given as follows: x � (2) Softmax function is used in equation (1) to ensure that the probabilities add up to 1, which is presented in the following equation: where θ � Y 0 X 0 + Y 1 X 1 + . . . + Y n X n can be written as shown in the following equation: Now, selecting 5 most probable candidates, the ground truth vector is defined in the following equation: en, the error function "E" is calculated and given in the following equation: where d � 0; if CV i � GV n , else d � 1. erefore, the loss function for this particular example is given in the following equation:  Computational Intelligence and Neuroscience

Xception.
e Xception architecture is based on the ImageNet database [14], like VGGNet. is architecture is comprised of 36 layered deep separable convolutional layers for feature extraction. Xception functions on a specific type of CNN are known as the depth-wise separable CNN. e properties of such a network included the use of a fewer number of parameters in order to reduce the chances of overfitting, and they became more compatible and computationally cheaper because of their less complex nature. e process of depth-wise separable CNN is divided into depth-wise convolution and pointwise convolution, as shown in Figures 4 and 5. e depth-wise operation comprised of a convolution being applied to a single channel at a time unlike the CNN operation where it is applied at all "N" channels.
Given the N channels of input, the filter/kernel size for depth-wise operation is defined as Df * Df * 1; the output size is summarized as Dk * Dk * N. A single convolutional operation required multiplication of Df * Df across N channels giving the total number of multiplications as N * Dk * Dk * Dp * Dp; this can be summarized as N * Df 2 * Dk 2 . For point-wise operation, a single convolution consists of 1 * N multiplication, also written as Dk * Dk times.
erefore, the total number of multiplications is "N * Dk * Dk * M," where M is the total number of filters. Hence, total number of multiplications in point-wise convolutional operation became N * Dk 2 * M. e overall operation is presented in the following equation: 2.3. Literature Review. AI and deep learning-based detection techniques via medical imaging are gaining popularity because of their promising results in various medical fields. Additionally, there is no lack of data available for training various machine learning-based models. Further, transfer learning has eased this process significantly through the usage of pretrained models that use a lesser number of images in retaining the learned information and detecting it with greater accuracy. Various researchers have used AIand CNN-based techniques to find the presence of brain tumors [15], lesions [16], breast cancer [17], etc., as summarized in Table 1. CNN is used on CT scans to identify the nature of the malignant pulmonary nodes [18], along with pneumonia via chest imaging scans [19,20]. Chouhan et al. [21] implemented deep learning architecture to detect the presence of pneumonia using the AlexNet, DenseNet121, InceptionV3, ResNet18, and GoogLeNet neural networks. Mahmud et al. [22] proposed an efficient technique for training an efficient deep neural network using relevant, available X-ray images so that the learned parameters could be utilized to detect COVID-19 instances even though the available COVID-19 X-ray dataset contained fewer images. Based on deep learning algorithms and unique features, Gu et al. [23] proposed an automated bacterial or viral pneumonia diagnostic approach to chest radiographs. On chest CT examinations, Li et al. [24] utilized a deep learning technique to identify COVID-19 and community-acquired pneumonia (CAP) using a deep learning method. Finally, a powerful deep learning model was developed for identifying COVID-19 and CAP from chest CT scans. ese findings have shown a convolutional network model-based machine-learning strategy to discriminate COVID-19 from CAP. Rajpurkar et al. [25] demonstrated CheXNeXt, a deep learning algorithm that detected various thoracic diseases in frontal-view chest radiographs, as well as practicing boardcertified radiologists. ey developed and evaluated a deep learning system that accurately detected clinically significant abnormalities in chest radiographs, on par with expert radiologists. Chowdhury et al. [26] proposed a deep CNNbased transfer learning method for automatically identifying COVID-19 pneumonia. e authors trained, validated, and assessed eight popular and previously reported effective CNN-based deep learning algorithms for distinguishing pneumonia patients from normal ones, using chest X-ray pictures. When image augmentation was not used, CheX-Net, a DenseNet descendant, outperformed the other networks. ereafter, Liang and Zheng [27] demonstrated an automated diagnostic method that differentiated between normal and pneumonia-affected children's chest X-ray pictures. ey built a new network architecture with residual components to better comprehend the effective textural properties of the lung tissue. ere were 49 convolutional layers in the network, as well as the ReLU activation, one global average pooling layer, and two dense layers. Ho and Gwak [28] offered a unique framework for integrating numerous characteristics from both shallow and deep features. After completing extensive tests, representative and discriminative characteristics were developed to differentiate 14 diseases from the public chest X-ray dataset. e use of deep learning (DL) algorithms to analyze lung ultrasonography (LUS) images was studied by Roy et al. [29]. e authors provided a new and completely annotated dataset of Computational Intelligence and Neuroscience  To diagnosis chest radiograph using deep learning method e 420 radiographs were labeled by radiologists in an average of 240 minutes, and the algorithm labeled them in 1.5 minutes LUS images obtained from several Italian hospitals, with labels representing the illness severity on a frame-by-frame, video-by-video, and pixel-by-pixel basis. Table 1 presents the summary of some of the AI and machine learning techniques used for the detection of different diseases. After reviewing the current state of the art, it can be confirmed that AI and machine learning techniques are used to investigate chest X-rays to ascertain the presence of any disease, including COVID-19 infection. Further, there is currently no dearth of datasets to train and test the results.
is paves the way to develop a mechanism to detect COVID-19 infection.

Proposed Methodology
e conventional methodologies in COVID-19 testing like the antigens, antibodies, and RT-PCR are associated with high-end medical infrastructure and cost and suffered from delays. Also, on the qualitative front, it bears poor detection accuracy and reported only 70% accuracy. As lung inflammation and infection are common across various COVID-19 cases, the use of a chest X-ray is considered a viable option.
is section introduces a model based on CNN and deep learning techniques to detect COVID-19induced pneumonia using chest X-rays. is work also made a distinction between COVID-19-induced pneumonia and regular pneumonia as the latter is a common disease, and one should not confuse it with the former, which is more lethal and fatal. e proposed model utilizes deep learning, transfer learning, and a pretrained model Xception on various training and testing ratios and consists of 4 phases presented in Figure 6. e proposed workflow model of this network is demonstrated in Figure 7, where firstly, the acquired labeled data are preprocessed, then split into 80 : 20, 70 : 30, and 60 : 40 ratios of test and train, applied with image augmentation properties. Furthermore, the images are subjected to various pretrained models such as VGG16, VGG19, and Xception that involve transfer learning techniques. If the accuracy is not adequate in one ratio, the images are trained again with a different set of ratios. e models are chosen based on their accuracy and other evaluations. e chosen models are included in this study with their classification performance.

Phase I: Dataset
Description. Medical scans in form of chest X-rays are essential for a computerized diagnosis. is work uses a curated dataset for COVID-19 posterior-anterior chest radiography images (X-ray) proposed by Sait et al. [30].
is dataset compiled 15 publicly available datasets and removed unwanted properties like noise, pixelation, and  Figure 8. Table 2 shows that the images were divided into three classes with various training and validation distributions. ese scans were further subjected to augmentation properties depending on the accuracy they provided.

Phase II:
Preprocessing. Image preprocessing involves balancing the elements of an image in accordance with the need of the proposed model, which can greatly affect accuracy and prediction. e input scans obtained from the dataset were rescaled and reshaped to the desired size (224 × 224), along with other augmentation properties before training the model. Image augmentation properties included removal of unwanted noise, pixelation, medical implants, compression, zooming, cropping, and images with labels. e scans were also rotated, shifted, and improved in sheerness and brightness. Image augmentation highly influenced a model's training time and performance. e detailed operations that were carried out are provided in Table 3.

Phase III: Training and Validation.
e augmented images were trained in CNN, Xception, VGG19, and VGG16 with the same properties shown in Table 4. e Xception model provided the highest accuracy and the shortest time compared with the other two models. e images were split in a ratio of 80 : 20, 70 : 30, and 60 : 40 for training and validation.

Phase IV: Results and Classification.
e custom-built CNN model and the pretrained models (Xception, VGG19, and VGG16) were tested for 15 epochs with 800 steps each.
e experiments were carried out on three train and test ratio combinations of 80 : 20, 70 : 30, and 60 : 40, wherein 80% of the total images were for training purposes and 20 for testing. is paper discusses the results obtained on the 80 : 20 ratio, as it is the most efficient one when compared with the other two ratios and was performed on the Google collaboratory platform with the GPU runtime as provided. Further, along with the performance, the detections are displayed using a confusion matrix, and the classification reports along with the detection of COVID-19-induced and regular pneumonia are shown through the heatmaps in

Experimentations and Result Analysis
is section presents the experimental results of the proposed model with CNN for their comparison against the pretrained models. e CNN method is built with each of the custom layers being defined well. e difference between CNN and the pretrained models is that the latter utilize transfer learning, while CNN does not. e image augmentation and training parameters are the same in both kinds of models.

Model-Wise Experimentation.
e layers of the CNN model are shown in Figure 10; the model consists of several convolutional layers followed by max-pooling, flatten, dropout, and dense layers. e classification results of CNN were calculated through a confusion matrix, and other matrices like the F1 score, recall, precision, sensitivity, specificity, FOR, FNR, FPR, and FDR. ese experiments were conducted for formulating a model that can accurately distinguish between COVID-19induced pneumonia, regular pneumonia, and healthy lungs. Table 5 and Figures 11(a)-11(d) present the experimental results, using different networks for training and validation accuracy against different training and test set ratios.
ese experimental results show that the CNN model achieves its best performance using the 80%-20% train-totest ratio with 2,842 training samples and 1,281 test samples. With this ratio, the CNN reported a training accuracy of 89%, while its validation accuracy remained at 93%, a bit lower than Xception with minimal loss. For the same network, the 70%-30% and 60%-40% train-to-test ratios yielded a training accuracy of 90% and 89%, respectively, 8 Computational Intelligence and Neuroscience and a validation accuracy of 94% and 90%, respectively. ese results also provide a comparison to the training and validation accuracy of other networks in the 80%-20%, 70%-30%, and 60%-40% train-to-test combinations. e observations clearly indicate that all networks report a higher training and validation accuracy as the training set size increases. Figure 12 shows the training and validation accuracy for all models with different train-to-test ratios.      Xception revealed that VGG19 reported the highest training accuracy, while Xception and VGG16 presented the highest validation accuracy. Xception also yielded better training accuracy than VGG16. Lastly, the functioning of the proposed method through the distinct layers is shown in Figure 13.

Confusion Matrix Evaluation.
A confusion matrix represents various qualitative parameters [31,32]. Ideally, the true positive rate and the true negative rate should be close to 100% in order to provide correct classification.
Similarly, the false positive and false negative rates should be as close to 0% as possible to reduce the chances of incorrect detection. Different classification matrices are given as follows: (i) Accuracy: accuracy expresses the number of data instances identified correctly over the total number of data instances given in the following equation:   Figure 10: CNN layer-wise architecture.
Computational Intelligence and Neuroscience

12
Computational Intelligence and Neuroscience (ii) Precision/positive predicted value: precision, as shown in equation (10), is the ratio of the positive cases identified correctly to all the positive cases expected.
(iii) Recall/sensitivity/true positive rate: the instances that are correctly defined as positive cases compared to all the real positive cases are recall, as shown in the following equation: (iv) F1 score: the harmonic mean of accuracy and recall is the F1 metric; it is a better metric than accuracy, as illustrated in the following equation: (v) Specificity/true negative rate: it is the number of true labels that lie in the class, shown in the following equation: Val_loss 600 700 Step model_name: Xception, training_ratio: 0.6 model_name: VGG19, training_ratio: 0.6 model_name: VGG16, training_ratio: 0.6 model_name: CNN, training_ratio: 0.6 model_name: Xception, training_ratio: 0.8 Step (d) (vi) False discovery rate: the ratio of false positive results to the total of false positive and true positive results observed shown in equation (13).
(vii) False negative rate: the error that signified that a particular condition did not hold while it existed, referred in the following equation: (viii) False omission rate: the ratio in a test for a condition being probably true provided that the results are deemed as false, illustrated in the following equation: (ix) False positive rate: the probability that a false value is given wherein a result is declared positive, while its true value is negative, presented in the following equation: Confusion matrices of the experimental results are presented in Figures 14(a) Table 6 demonstrates the confusion matrix evaluation of the three classes by showcasing the training-testing ratio and classifying the images as TP, TN, FP, and FN. Experimental results were calculated for train-to-test ratios like 80 : 20, 70 : 30, and 60 : 40, respectively. e total numbers of validation data were 812, 1,218, and 1,624. Number of images classified in terms of FN, FP, TN, and TP by each model. Out of these data, a majority were reported in the true positive and true negative classes, making them rightly classified. Xception and VGG19 network classified the highest greatest number of images correctly in 80 : 20 ratio and reported the lowest number of images detected wrongly, while successfully detecting 799 images with precision. Table 7 presents the various performance matrices as shown in equations (9)- (17).
ese results illustrate the classification report of the three classes-COVID-19, normal, and regular pneumonia-with the total number of images that were correctly detected, incorrectly detected, and not detected at all. Experimental results revealed that COVID-19 detection accuracy in 80 : 20 train-to-test ratio remained as high as 98% for all the network models. is is quite significant when compared to conventional tests used to detect COVID-19 presence. However, for the "normal" category, different networks reported different detection accuracy-96% for CNN, 94% for VGG16 and VGG19, and 97% for Xception-for 80 : 20 train-to-test ratio. Similarly, different networks again yielded different detection rates for "regular pneumonia," for which detection accuracy for CNN, VGG16, VGG19, and Xception remained at 97%, 94%, 95%, and 96%, respectively, for 80 : 20 train-to-test ratio. Other result matrices followed the same trend, reporting better values for greater training set size. Experimental results presented in Table 8 illustrate the classification report for each network in three different testing-and-training ratio. Out of all the ratios, the 80 : 20 train-and-test ratio reported the most encouraging results.

Conclusion
e paper presented a mechanism that embraced the ideas of deep learning, deep neural networks, convolutional neural networks, and transfer learning theories and that successfully identified COVID-19 and COVID-19-induced pneumonia using chest X-rays. e proposed work used transfer learning to report encouraging and accurate experimental results, as it did not require a large dataset. Experimental results also alleviated concern regarding overlap between diagnoses of COVID-19 and regular pneumonia. e custom CNN and transfer learning architectures trained on various training and testing ratios provide enough evidence in terms of efficiency. e detection accuracy stands at 98% for all the networks. For other combinations, Xception and VGG16 showcase similar results, but Xception can be categorized as better because its loss value is better than other networks. e proposed methodology works effectively and differentiates the two infections (COVID-19/COVID-19-induced pneumonia and regular pneumonia), which can benefit the medical infrastructure with further integrations. e application of artificial intelligence exhibits a lot of scope in the detection and diagnosis of COVID-19 and regular pneumonia by training this model on other lung infections. erefore, strengthening the dataset in size will increase its efficiency and will amplify its application. Furthermore, other deep learning models like GoogLeNet and AlexNet can apply to chest X-ray datasets to obtain promising results.

Data Availability
e data used to support the findings of this study are included within the article.

Conflicts of Interest
All the authors declare no conflicts of interest.